{extend name="../admin/common/base" /}
{block name="jscss"}
{js href='__STATIC__/zclip/jquery.zclip.min.js' /}
{/block}
{block name="body"}

<div style="padding: 0px 10px 0px 10px;">
    <table class="layui-table" lay-skin="line">
        <thead>
            <tr>
                <th>公众号接口通信配置</th>
                <th></th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>URL(服务器地址)</td>
                <td class="apiUrl"><span id="apiUrl">{$mp.url}</span><span class="tip1 rha-bt-a"></span></td>
                <td><a href="javascript:;" onclick="BtnClick('apiUrl')" class="rha-bt-a">复制</a></td>
            </tr>
            <tr>
                <td>Token(令牌)</td>
                <td class="valid_token"><span id="valid_token">{$mp.valid_token}</span><span class="tip2 rha-bt-a"></span></td>
                <td><a href="javascript:;" onclick="BtnClick('valid_token')" class="rha-bt-a">复制</a></td>
            </tr>
            <tr>
                <td>EncodingAESKey<br>(消息加解密密钥)</td>
                <td class="encodingaeskey"><span id="encodingaeskey" >{$mp.encodingaeskey}</span><span class="tip3 rha-bt-a"></span></td>
                <td><a href="javascript:;" onclick="BtnClick('encodingaeskey')" class="rha-bt-a">复制</a></td>
            </tr>
            <tr>
                <td>IP白名单</td>
                <td class="server_ip"><span id="server_ip">{:get_server_ip()}</span><span class="tip4 rha-bt-a"></span></td>
                <td><a href="javascript:;" onclick="BtnClick('server_ip')" class="rha-bt-a">复制</a></td>
            </tr>
        </tbody>
    </table>
</div>
<script type="text/javascript">
    function copyText(text) {
        var textarea = document.createElement("textarea");
        var currentFocus = document.activeElement;
        document.body.appendChild(textarea);
        textarea.value = text;
        textarea.focus();
        if (textarea.setSelectionRange)
            textarea.setSelectionRange(0, textarea.value.length);
        else
            textarea.select();
        try {
            var flag = document.execCommand("copy");
        } catch (eo) {
            var flag = false;
        }
        document.body.removeChild(textarea);
        currentFocus.focus();
        return flag;
    }
    function BtnClick(name) {
        var a = document.getElementById(name).innerHTML;
        var flag = copyText(a);//这个必须在DOM对象的事件线程中执行
        alert(flag ? "复制成功！" : "复制失败！");
    };
</script>
{/block}